﻿@model IList<SmartStore.Web.Models.ShoppingCart.ShoppingCartModel.CheckoutAttributeModel>
@using SmartStore.Core.Domain.Catalog;
@if (Model.Count > 0)
{
    
    <div class="checkout-attributes well well-small">

        <div class="form-vertical">
            @foreach (var attribute in Model)
            {
                string controlId = string.Format("checkout_attribute_{0}", attribute.Id);
                string textPrompt = !string.IsNullOrEmpty(attribute.TextPrompt) ? attribute.TextPrompt : attribute.Name;
                <div class="control-group">
                    <label for="@controlId" class='control-label@(attribute.IsRequired ? " required" : "")'>@textPrompt</label>
                    <div class="controls">
                        @switch (attribute.AttributeControlType)
                        {
                            case AttributeControlType.DropdownList:
                                {
                            <select name="@(controlId)" id="@(controlId)" style="width:100%">
                                @if (!attribute.IsRequired)
                                {
                                    <option value="0">---</option>
                                }
                                @foreach (var caValue in attribute.Values)
                                {
                                    <option selected="@caValue.IsPreSelected" value="@caValue.Id">@caValue.Name
                                        @(!String.IsNullOrEmpty(caValue.PriceAdjustment) ? " [" + caValue.PriceAdjustment + "]" : null)
                                    </option>
                                }
                            </select>
                                }
                                break;
                            case AttributeControlType.RadioList:
                                {
                                    foreach (var caValue in attribute.Values)
                                    {
                                        <label for="@(controlId)_@(caValue.Id)" class="radio">
                                            <input id="@(controlId)_@(caValue.Id)" type="radio" name="@(controlId)" value="@caValue.Id" checked="@caValue.IsPreSelected" />
                                                @caValue.Name @(!String.IsNullOrEmpty(caValue.PriceAdjustment) ? " [" + caValue.PriceAdjustment + "]" : null)
                                        </label>
                                    }
                                }
                                break;
                            case AttributeControlType.Checkboxes:
                                {
                                    foreach (var caValue in attribute.Values)
                                    {
                                        <label for="@(controlId)_@(caValue.Id)" class="checkbox">
                                            <input id="@(controlId)_@(caValue.Id)" type="checkbox" name="@(controlId)" value="@caValue.Id" checked="@caValue.IsPreSelected" />
                                                @caValue.Name @(!String.IsNullOrEmpty(caValue.PriceAdjustment) ? " [" + caValue.PriceAdjustment + "]" : null)
                                        </label>
                                    }
                                }
                                break;
                            case AttributeControlType.TextBox:
                                {
                            <input name="@(controlId)" type="text" class="textbox input-block-level" id="@(controlId)" @(!String.IsNullOrWhiteSpace(attribute.DefaultValue) ? " value=" + attribute.DefaultValue : null) />
                                }
                                break;
                            case AttributeControlType.MultilineTextbox:
                                {
                            <textarea id="@(controlId)" class="input-block-level" name="@(controlId)">@(!String.IsNullOrWhiteSpace(attribute.DefaultValue) ? attribute.DefaultValue : null)</textarea>
                                }
                                break;
                            case AttributeControlType.Datepicker:
                                {
                            @Html.DatePickerDropDowns(controlId + "_day", controlId + "_month", controlId + "_year", DateTime.Now.Year, DateTime.Now.Year + 1, attribute.SelectedDay, attribute.SelectedMonth, attribute.SelectedYear)
                                }
                                break;
                            case AttributeControlType.FileUpload:
                                {
                            <input type="file" id="@(controlId)" name="@(controlId)"></input>
                                }
                                break;
                        }
                    </div>
                </div>
            }
        </div>
    </div>
}